package com.ruoyi.stuinfo.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.stuinfo.domain.Dormitorybuilding;
import com.ruoyi.stuinfo.service.IDormitorybuildingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 楼宇详情Controller
 * 
 * @author zc
 * @date 2025-05-13
 */
@RestController
@RequestMapping("/stuinfo/dormitorybuilding")
public class DormitorybuildingController extends BaseController
{
    @Autowired
    private IDormitorybuildingService dormitorybuildingService;

    /**
     * 查询楼宇详情列表
     */
    @PreAuthorize("@ss.hasPermi('stuinfo:dormitorybuilding:list')")
    @GetMapping("/list")
    public TableDataInfo list(Dormitorybuilding dormitorybuilding)
    {
        startPage();
        List<Dormitorybuilding> list = dormitorybuildingService.selectDormitorybuildingList(dormitorybuilding);
        return getDataTable(list);
    }

    /**
     * 导出楼宇详情列表
     */
    @PreAuthorize("@ss.hasPermi('stuinfo:dormitorybuilding:export')")
    @Log(title = "楼宇详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Dormitorybuilding dormitorybuilding)
    {
        List<Dormitorybuilding> list = dormitorybuildingService.selectDormitorybuildingList(dormitorybuilding);
        ExcelUtil<Dormitorybuilding> util = new ExcelUtil<Dormitorybuilding>(Dormitorybuilding.class);
        util.exportExcel(response, list, "楼宇详情数据");
    }

    /**
     * 获取楼宇详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('stuinfo:dormitorybuilding:query')")
    @GetMapping(value = "/{buildingId}")
    public AjaxResult getInfo(@PathVariable("buildingId") String buildingId)
    {
        return success(dormitorybuildingService.selectDormitorybuildingByBuildingId(buildingId));
    }

    /**
     * 新增楼宇详情
     */
    @PreAuthorize("@ss.hasPermi('stuinfo:dormitorybuilding:add')")
    @Log(title = "楼宇详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Dormitorybuilding dormitorybuilding)
    {
        return toAjax(dormitorybuildingService.insertDormitorybuilding(dormitorybuilding));
    }

    /**
     * 修改楼宇详情
     */
    @PreAuthorize("@ss.hasPermi('stuinfo:dormitorybuilding:edit')")
    @Log(title = "楼宇详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Dormitorybuilding dormitorybuilding)
    {
        return toAjax(dormitorybuildingService.updateDormitorybuilding(dormitorybuilding));
    }

    /**
     * 删除楼宇详情
     */
    @PreAuthorize("@ss.hasPermi('stuinfo:dormitorybuilding:remove')")
    @Log(title = "楼宇详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{buildingIds}")
    public AjaxResult remove(@PathVariable String[] buildingIds)
    {
        return toAjax(dormitorybuildingService.deleteDormitorybuildingByBuildingIds(buildingIds));
    }
}
